package exception.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author quan
 * @Description 模拟异常情况
 * @Date 2023/7/29 10:29
 */
@Slf4j
@ResponseBody
@RestController
@RequestMapping("/web")
public class ErrorController {
    //算数异常
    @RequestMapping("/test01")
    public boolean test01(){
        int a = 10/0;
        return true;
    }

    //空指针异常
    @RequestMapping("/test02")
    public boolean test02(){
        String str = null;
        System.out.println(str.length());
        return true;
    }

    //手动抛出异常
    @RequestMapping("/test03")
    public boolean test03(){
        throw new RuntimeException("test03手动抛出异常");
    }
}
